﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CancerPanleReport.core;
using CancerPanleReport.form;
using System.Diagnostics;
using System.IO;

namespace CancerPanleReport.bform
{
    public partial class AnalysisForm : BaseForm
    {
        public AnalysisForm()
        {
            InitializeComponent();

            LoadComboBoxItem(methodList, "AnalysisForm.methodList", "name", "action");

            LoadComboBoxItem(templateList, "AnalysisForm.templateList", "name", "action");

        }

        private void btnFile_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == openFileDialog1.ShowDialog())
            {
                filePath.Text = openFileDialog1.FileName;
            }
        }

        private void analyse_Click(object sender, EventArgs e)
        {
            string action = methodList.SelectedValue as string;

            string path = templateList.SelectedValue as string;

            Dictionary<string, object> actionParams = new Dictionary<string, object>();
           
            actionParams.Add("name", "demo");
            actionParams.Add("filePath", filePath.Text);

            string outDir = string.Format(@"{0}{1}{2:yyyyMMddHHmmss}\",
                                Environment.CurrentDirectory,
                                LoadString("AnalysisForm.WorkDirectory"),
                                DateTime.Now
                                );

            Directory.CreateDirectory(outDir);

            string outFilePath = string.Format(@"{0}{1}",
                outDir,
                LoadString("AnalysisForm.FileName"));

            actionParams.Add("outFilePath", outFilePath);
           
         
            actionParams.Add("key", "AnalysisForm.Template");
            actionParams.Add("key01","123");
            actionParams.Add("COSMIC_ID", "736");
            actionParams.Add("DRUG", "cediranib");

            List<object> obj = ActionControllerWrap.Instance.DoAction(action, actionParams) as List<object>;


            actionParams.Add("obj", obj);

            

            ActionControllerWrap.Instance.DoAction("/word/build.do", actionParams);
            MessageBox.Show("分析成功");
            Process.Start(outFilePath);


        }
    }
}
